# try中的代码没有异常就会走else.出现异常还是走 except

# try:
#     f = open('1.txt', 'r')
# except Exception as e:
#     print(e)
# else:
#     content = f.readlines()
#     print(content)
#     f.close()

print('---------------------')
f = None
try:
    f = open('python.txt', 'r')
except:
    f = open('python.txt', 'w')
else:
    content = f.readlines()
    print(content)
finally:
    f.close()
    print('---资源释放了--------')